﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Jumpton.SFA.Server.Entity;
using Jumpton.Persistent;
using Jumpton.Data;
using System.Data;

namespace Jumpton.SFA.Server.BusinessRule.CallRoute
{
    public class TempleteManager
    {
        /// <summary>
        /// 获取单条记录
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public Templete Load(decimal id)
        {
            return (Templete)ObjectRow.Load(typeof(Templete), string.Format("this.ID={0}", id));
        }

        /// <summary>
        /// 获取模板类型 保证一个类型只有一个模板
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public Templete GetTempleteType(decimal type)
        {
            return (Templete)ObjectRow.Load(typeof(Templete), string.Format("this.Type={0}", type));
        }

        /// <summary>
        /// 获取所有模板记录
        /// </summary>
        /// <returns></returns>
        public ObjectTable GetAllTempleteView()
        {
            return new ObjectTable(typeof(TempleteView)); 
        }      

        /// <summary>
        /// 新增或修改模板
        /// </summary>
        /// <param name="t"></param>
        public void Save(Templete templete)
        {
            if (templete != null)
                templete.Save();
        }
    }
}
